<template>
	<div class="count-sales">
		<div class="card">
			<div class="card__header">
				<span class="label">订单总数</span>
				<span class="value">{{ state.orderTotal }}</span>
			</div>
			<div class="card__container">
				<ul class="count-sales__cop">
					<li>
						<span>已支付</span>
						<div class="fall">
							<!-- <el-icon>
								<top-right v-if="state.weekly > 0" />
								<bottom-right v-else />
							</el-icon> -->
							<span>{{ state.orderHavePaid }}</span>
						</div>
					</li>

					<li>
						<span>未支付</span>
						<div class="rise">
							<!-- <el-icon>
								<top-right v-if="state.yesterday > 0" />
								<bottom-right v-else />
							</el-icon> -->
							<span>{{ state.orderNotHavePaid }}</span>
						</div>
					</li>
				</ul>
			</div>
			<div class="card__footer">
				<div class="card_btn">
					<span class="label">今日订单数</span>
					<span class="value">{{ state.currentDay }}</span>
				</div>
				<div class="card_btn">
					<span class="label">昨日订单数</span>
					<span class="value">{{ state.yesterday }}</span>
				</div>
			</div>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { BottomRight, TopRight } from "@element-plus/icons-vue";

import { onMounted, reactive } from "vue";
import { useCool } from "/@/cool";
const { service } = useCool();

const state = reactive({
	orderTotal: 38,
	weekly: 200,
	yesterday: 0,
	currentDay: -100,
	orderHavePaid: 0,
	orderNotHavePaid: 0
});

const getOrderTotal = async () => {
	let { orderTotal, weekly, yesterday, currentDay, orderHavePaid, orderNotHavePaid } =
		await service.member.info.orderTotal();
	state.orderTotal = orderTotal;
	state.weekly = weekly;
	state.yesterday = yesterday;
	state.currentDay = currentDay;
	state.orderHavePaid = orderHavePaid;
	state.orderNotHavePaid = orderNotHavePaid;
};

onMounted(() => {
	getOrderTotal();
});
</script>

<style lang="scss" scoped>
.count-sales {
	&__cop {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 50px;

		li {
			display: flex;
			list-style: none;
			flex: 1;
			color: var(--el-color-info);

			.fall,
			.rise {
				display: flex;
				align-items: center;
				margin-left: 10px;
			}

			.fall {
				color: #13ae7c;
			}

			.rise {
				color: #f21e37;
			}
		}
	}
}
.card_btn {
	margin-right: 15px;
}
</style>
